package org.one.webapp;

import com.alibaba.fastjson.JSONObject;
import org.one.servlet.OneRequest;
import org.one.servlet.OneResponse;
import org.one.servlet.OneServlet;

import java.util.List;
import java.util.Map;

/**
 * @Classname : HelloServlet
 * @Description : servlet demo
 * @Author : cty
 * @Date 2023/6/12 22:18
 */


public class HelloServlet extends OneServlet {

    @Override
    public void doGet(OneRequest request, OneResponse response) throws Exception {
        JSONObject resp = new JSONObject();
        Map<String, List<String>> paramsMap = request.getParameters();
        resp.put("title", "Hello Hero");
        JSONObject params = new JSONObject();
        for (String key : paramsMap.keySet()) {
            params.put(key, paramsMap.get(key).get(0));
        }
        resp.put("params", params);
        response.write(resp.toJSONString());
    }

    @Override
    public void doPost(OneRequest request, OneResponse response) throws Exception {

    }
}
